IF EXISTS (SELECT * FROM sysobjects WHERE type = 'P' AND name = 'InvoiceCreate')
	BEGIN
		DROP  Procedure InvoiceCreate
	END

GO

CREATE Procedure InvoiceCreate
(
	@accountId int,
	@invoiceRef nvarchar(50),
	@recipientRef nvarchar(50),
	@invoiceDate datetime,
	@typeFlag int,
	@invoiceId int OUTPUT
)
AS

INSERT INTO Invoices
	(AccountId, InvoiceRef, RecipientRef, InvoiceDate, TypeFlag, CreateDate, UpdateDate)
VALUES
	(@accountId, @invoiceRef, @recipientRef, @invoiceDate, @typeFlag, GETDATE(), GETDATE())

SET @invoiceId = SCOPE_IDENTITY()

GO